package com.bifrost.entity;

import java.io.Serializable;
import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
import java.math.BigInteger;
import java.util.List;


/**
 * The persistent class for the ORDER_ITEM database table.
 *
 * @author joewee
 */
@Entity
@Table(name = "ORDER_ITEM")
@NamedQuery(name = "OrderItem.findAll", query = "SELECT o FROM OrderItem o")
public class OrderItem implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ORDER_ITEM_ID", unique = true, nullable = false)
    private Long orderItemId;

    @Column(name = "APPLIED_PROMO_ID")
    private Long appliedPromoId;

    @Column(name = "BONUS_POINTS", precision = 11)
    private Integer bonusPoints = Integer.valueOf(0);

    @Column(name = "CUSTOMER_MESSAGE", length = 255)
    private String customerMessage;

    @Column(name = "HAS_SERVICE")
    private Boolean hasService = Boolean.FALSE;
    @Column(name = "HAS_GIFT")
    private Boolean hasGift = Boolean.FALSE;

    @Column(name = "IS_PROMO_APPLIED")
    private Boolean isPromoApplied = Boolean.FALSE;

    @Column(name = "ORDER_ITEM_TYPE", length = 32, nullable = false)
    private String orderItemType;

    @Column(name = "RETAIL_PRICE", nullable = false, precision = 19, scale = 5)
    private BigDecimal retailPrice;

    @Column(name = "SKU_ID", nullable = false)
    private Long skuId;
    @Column(name = "CATEGORY_ID", nullable = false)
    private Long categoryId;
    @Column(name = "PRODUCT_ID", nullable = false)
    private Long productId;

    @Column(name = "SKU_NAME", nullable = false)
    private String skuName;

    @Column(name = "SKU_PRICE", nullable = false, precision = 19, scale = 5)
    private BigDecimal skuPrice;
    @Column(name = "SKU_COST", precision = 19, scale = 5)
    private BigDecimal skuCost;

    @Column(name = "SKU_UPC", length = 32)
    private String skuUPC;
    @Column(name = "EXTERNAL_ID", length = 32)
    private String externalId;
    @Column(name = "SKU_QUANTITY", nullable = false, precision = 11)
    private Integer skuQuantity;

    @Column(name = "SUPPLIER_ID")
    private BigInteger supplierId;

    @Column(name = "TAX_CODE", length = 32)
    private String taxCode;

    @Column(name = "TAX_EXCLUSIVE_OF_PRICE")
    private Boolean taxExclusiveOfPrice;

    @Column(name = "TAX_RATE",  precision = 19, scale = 5)
    private BigDecimal taxRate;

    @Deprecated
    @Column(name = "GIFT_WRAP_ITEM_ID")
    private Long giftWrapItemId;

    @Column(name = "UPDATED_BY", length = 64)
    private String updatedBy;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "UPDATED_TIMESTAMP")
    private Date updatedTimestamp = new Date();

    @Column(name = "RETURN_QUANTITY")
    private Integer returnQuantity = 0;

    @OneToMany(mappedBy = "orderItem", cascade = {CascadeType.ALL})
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<GiftwrapOrderItem> giftwrapOrderItems;

    @OneToMany(mappedBy = "orderItem", cascade = {CascadeType.ALL})
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<OrderBundleItem> orderBundleItems;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ORDER_ID" ,foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private Order order;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SNAPSHOT_ID" ,foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private SkuSnapshot skuSnapshot;

    @OneToMany(mappedBy = "orderItem", cascade = {CascadeType.ALL})
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<OrderItemDownload> orderItemDownloads;

    @OneToMany(mappedBy = "orderItem", cascade = {CascadeType.ALL})
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<OrderItemService> orderItemServices;

    @Column(name = "DISCOUNT_SHARE", nullable = false, precision = 19, scale = 5)
    private BigDecimal discountShare = BigDecimal.ZERO;

    @Column(name = "SHIP_SHARE", nullable = false, precision = 19, scale = 5)
    private BigDecimal shipShare = BigDecimal.ZERO;

    @Column(name = "STATUS", length = 32)
    private String status;

    @Column(name = "COUPON_CODE")
    private Long couponCode;

    public OrderItem() {
    }


    public OrderItem(Long orderItemId,String externalId,BigDecimal skuPrice,Integer skuQuantity) {
        this.orderItemId = orderItemId;
        this.externalId = externalId;
        this.skuPrice = skuPrice;
        this.skuQuantity = skuQuantity;
    }

    public Long getOrderItemId() {
        return this.orderItemId;
    }

    public void setOrderItemId(Long orderItemId) {
        this.orderItemId = orderItemId;
    }

    public Long getAppliedPromoId() {
        return this.appliedPromoId;
    }

    public void setAppliedPromoId(Long appliedPromoId) {
        this.appliedPromoId = appliedPromoId;
    }

    public Integer getBonusPoints() {
        return this.bonusPoints;
    }

    public void setBonusPoints(Integer bonusPoints) {
        this.bonusPoints = bonusPoints;
    }

    public String getCustomerMessage() {
        return this.customerMessage;
    }

    public void setCustomerMessage(String customerMessage) {
        this.customerMessage = customerMessage;
    }

    public Boolean hasGift() {
        return hasGift;
    }

    public void setHasGift(Boolean hasGift) {
        this.hasGift = hasGift;
    }

    public Boolean getHasService() {
        return this.hasService;
    }

    public void setHasService(Boolean hasService) {
        this.hasService = hasService;
    }

    public Boolean isPromoApplied() {
        return this.isPromoApplied;
    }

    public void setIsPromoApplied(Boolean isPromoApplied) {
        this.isPromoApplied = isPromoApplied;
    }

    public String getOrderItemType() {
        return this.orderItemType;
    }

    public void setOrderItemType(String orderItemType) {
        this.orderItemType = orderItemType;
    }

    public BigDecimal getRetailPrice() {
        return this.retailPrice;
    }

    public void setRetailPrice(BigDecimal retailPrice) {
        this.retailPrice = retailPrice;
    }

    public Long getSkuId() {
        return skuId;
    }

    public void setSkuId(Long skuId) {
        this.skuId = skuId;
    }

    public Long getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Long categoryId) {
        this.categoryId = categoryId;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public String getSkuName() {
        return this.skuName;
    }

    public void setSkuName(String skuName) {
        this.skuName = skuName;
    }

    public BigDecimal getSkuPrice() {
        return this.skuPrice;
    }

    public void setSkuPrice(BigDecimal skuPrice) {
        this.skuPrice = skuPrice;
    }

    public Integer getSkuQuantity() {
        return this.skuQuantity;
    }

    public void setSkuQuantity(Integer skuQuantity) {
        this.skuQuantity = skuQuantity;
    }

    public BigDecimal getSkuCost() {
        return skuCost;
    }

    public void setSkuCost(BigDecimal skuCost) {
        this.skuCost = skuCost;
    }

    public String getSkuUPC() {
        return skuUPC;
    }

    public void setSkuUPC(String skuUPC) {
        this.skuUPC = skuUPC;
    }

    public String getExternalId() {
        return externalId;
    }

    public void setExternalId(String externalId) {
        this.externalId = externalId;
    }

    public BigInteger getSupplierId() {
        return this.supplierId;
    }

    public void setSupplierId(BigInteger supplierId) {
        this.supplierId = supplierId;
    }

    public String getTaxCode() {
        return this.taxCode;
    }

    public void setTaxCode(String taxCode) {
        this.taxCode = taxCode;
    }

    public Boolean getTaxExclusiveOfPrice() {
        return this.taxExclusiveOfPrice;
    }

    public void setTaxExclusiveOfPrice(Boolean taxExclusiveOfPrice) {
        this.taxExclusiveOfPrice = taxExclusiveOfPrice;
    }

    public BigDecimal getTaxRate() {
        return this.taxRate;
    }

    public void setTaxRate(BigDecimal taxRate) {
        this.taxRate = taxRate;
    }

    public String getUpdatedBy() {
        return this.updatedBy;
    }

    public void setUpdatedBy(String updatedBy) {
        this.updatedBy = updatedBy;
    }

    public Date getUpdatedTimestamp() {
        return this.updatedTimestamp;
    }

    public void setUpdatedTimestamp(Date updatedTimestamp) {
        this.updatedTimestamp = updatedTimestamp;
    }

    public List<GiftwrapOrderItem> getGiftwrapOrderItems() {
        return this.giftwrapOrderItems;
    }

    public Long getCouponCode() {
        return couponCode;
    }

    public void setCouponCode(Long couponCode) {
        this.couponCode = couponCode;
    }

    public void setGiftwrapOrderItems(List<GiftwrapOrderItem> giftwrapOrderItems) {
        this.giftwrapOrderItems = giftwrapOrderItems;
    }

    public GiftwrapOrderItem addGiftwrapOrderItem(GiftwrapOrderItem giftwrapOrderItem) {
        getGiftwrapOrderItems().add(giftwrapOrderItem);
        giftwrapOrderItem.setOrderItem(this);

        return giftwrapOrderItem;
    }

    public GiftwrapOrderItem removeGiftwrapOrderItem(GiftwrapOrderItem giftwrapOrderItem) {
        getGiftwrapOrderItems().remove(giftwrapOrderItem);
        giftwrapOrderItem.setOrderItem(null);

        return giftwrapOrderItem;
    }

    public List<OrderBundleItem> getOrderBundleItems() {
        return this.orderBundleItems;
    }

    public void setOrderBundleItems(List<OrderBundleItem> orderBundleItems) {
        this.orderBundleItems = orderBundleItems;
    }

    public OrderBundleItem addOrderBundleItem(OrderBundleItem orderBundleItem) {
        getOrderBundleItems().add(orderBundleItem);
        orderBundleItem.setOrderItem(this);

        return orderBundleItem;
    }

    public OrderBundleItem removeOrderBundleItem(OrderBundleItem orderBundleItem) {
        getOrderBundleItems().remove(orderBundleItem);
        orderBundleItem.setOrderItem(null);

        return orderBundleItem;
    }

    public Order getOrder() {
        return this.order;
    }

    public void setOrder(Order order) {
        this.order = order;
    }

    public SkuSnapshot getSkuSnapshot() {
        return this.skuSnapshot;
    }

    public void setSkuSnapshot(SkuSnapshot skuSnapshot) {
        this.skuSnapshot = skuSnapshot;
    }

    public List<OrderItemDownload> getOrderItemDownloads() {
        return this.orderItemDownloads;
    }

    public void setOrderItemDownloads(List<OrderItemDownload> orderItemDownloads) {
        this.orderItemDownloads = orderItemDownloads;
    }

    public OrderItemDownload addOrderItemDownload(OrderItemDownload orderItemDownload) {
        getOrderItemDownloads().add(orderItemDownload);
        orderItemDownload.setOrderItem(this);

        return orderItemDownload;
    }

    public OrderItemDownload removeOrderItemDownload(OrderItemDownload orderItemDownload) {
        getOrderItemDownloads().remove(orderItemDownload);
        orderItemDownload.setOrderItem(null);

        return orderItemDownload;
    }

    public List<OrderItemService> getOrderItemServices() {
        return this.orderItemServices;
    }

    public void setOrderItemServices(List<OrderItemService> orderItemServices) {
        this.orderItemServices = orderItemServices;
    }

    public OrderItemService addOrderItemService(OrderItemService orderItemService) {
        getOrderItemServices().add(orderItemService);
        orderItemService.setOrderItem(this);

        return orderItemService;
    }

    public OrderItemService removeOrderItemService(OrderItemService orderItemService) {
        getOrderItemServices().remove(orderItemService);
        orderItemService.setOrderItem(null);

        return orderItemService;
    }

    public BigDecimal getDiscountShare() {
        return discountShare;
    }

    public void setDiscountShare(BigDecimal discountShare) {
        this.discountShare = discountShare;
    }

    public BigDecimal getShipShare() {
        return shipShare;
    }

    public void setShipShare(BigDecimal shipShare) {
        this.shipShare = shipShare;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Integer getReturnQuantity() {
        return returnQuantity;
    }

    public void setReturnQuantity(Integer returnQuantity) {
        this.returnQuantity = returnQuantity;
    }
}